/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: jzj
 * Date: 2024-03-24
 * Time: 14:30
 */
public class test_2 {
    public static int minCostClimbingStairs(int[] cost) {
        //1.建立dp表
        int n=cost.length;
        int[] dp=new int[n+1];
        //dp表，表示到达当前楼梯的最低费用
        //填表
        for (int i = 2; i < n+1; i++) {
            dp[i]=Math.min(dp[i-1]+cost[i-1],dp[i-2]+cost[i-2]);
        }
        return dp[n];

    }

    public static void main(String[] args) {
        int[] cost =new int[]{10,15,20};
        System.out.println(minCostClimbingStairs(cost));
    }
}
